package com.kira.solo.schedule.list

import androidx.compose.runtime.Immutable
import com.alipay.hulu.shared.io.bean.RecordCaseInfo
import com.kira.solo.schedule.pojo.CasePeriodTaskInfo
import java.text.DateFormat
import java.util.Date

/**
 *
 * @packageName com.kira.solo.schedule.list
 * @date 2024/1/24 14:51
 * @author zhanglei
 */
@Immutable
data class ScheduledCaseListUiState(val cases: List<ScheduledCaseUiState>) {
    companion object {
        val INIT = ScheduledCaseListUiState(emptyList())
    }
}

/**
 * 定时任务
 */
@Immutable
data class ScheduledCaseUiState(
    val casePeriodTaskInfo: CasePeriodTaskInfo,
    val cases: List<CaseUiState>,
)

@Immutable
data class CaseListUiState(val cases: List<CaseUiState>) {
    companion object {
        val INIT = CaseListUiState(emptyList())
    }
}

@Immutable
data class CaseUiState(
    val id: Long,
    val caseName: String,
    val caseDesc: String,
    val targetAppPackage: String,
    val targetAppLabel: String,
    val recordMode: String,
    val advanceSettings: String,
    val operationLog: String,
    val priority: Int,
    val gmtCreate: String,
    val gmtModify: String,
    val selected: Boolean,
)

val RecordCaseInfo.uiState: CaseUiState
    get() = CaseUiState(
        id,
        caseName,
        caseDesc,
        targetAppPackage,
        targetAppLabel,
        recordMode,
        advanceSettings,
        operationLog,
        priority,
        DateFormat.getDateTimeInstance().format(Date(gmtCreate)),
        DateFormat.getDateTimeInstance().format(Date(gmtModify)),
        selected
    )